import React from 'react'
import { Switch, Route, Redirect } from "react-router-dom"
import PrivateRoute from "./utils/PrivateRoute";

// 懒加载
let Register =React.lazy(()=>import("./containers/Register/Register.jsx")) 
let Login =React.lazy(()=>import("./containers/Login/Login.jsx")) 
let Index =React.lazy(()=>import("./containers/Index/Index.jsx")) 
let Detail =React.lazy(()=>import("./containers/Detail/Detail.jsx")) 

export default function App() {
  return (
    <React.Suspense fallback={<div>正在加载...</div>}>
        <Switch>
          <Route path="/register" component={Register}></Route>
          <Route path="/login" component={Login}></Route>
          <PrivateRoute path="/index" component={Index}></PrivateRoute>
          <PrivateRoute path="/detail/:id" component={Detail}></PrivateRoute>
          <Redirect to="/login"></Redirect>
        </Switch>
      </React.Suspense>
  )
}